package tesis.ProyectoFianl.Overlay;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;

import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class OverlayDescripcionRecorrido extends Overlay 
{
	private String corredor;
	private String ramal;

	public OverlayDescripcionRecorrido(String corredor, String ramal)
	{		
		this.corredor = corredor;
		this.ramal = ramal;
		
	}
	@Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) 
    {
		super.draw(canvas, mapView, shadow);
		if(mapView.getZoomLevel()>11)
		{
			                
	        int longitud = this.ramal.length();
	        Point scrnPoint = new Point(5,5);
	//        mapView.getProjection().toPixels(this.point, scrnPoint);
	//
	//        RectF oval = new RectF(scrnPoint.x - mRadius, scrnPoint.y - mRadius, 
	//        		scrnPoint.x + mRadius, scrnPoint.y + mRadius);
	
			// Setup the paint
			Paint paint = new Paint();
			paint.setARGB(255, 0, 0, 0);
			paint.setAntiAlias(true);
			paint.setFakeBoldText(true);
			
			Paint backPaint = new Paint();
			backPaint.setARGB(180, 50, 50, 50);
			backPaint.setAntiAlias(true);
			
			Paint textStyle = new Paint();
			textStyle.setARGB(250, 250, 250, 250);
			paint.setAntiAlias(true);
			paint.setFakeBoldText(true);
			
	//		RectF backRect = new RectF(scrnPoint.x + 2 + mRadius, scrnPoint.y - 3*mRadius,
	//				scrnPoint.x + 70, scrnPoint.y + mRadius);
			RectF backRect = new RectF(scrnPoint.x, scrnPoint.y,
					scrnPoint.x + longitud*6, scrnPoint.y + 35);
			
			// Draw the marker
	//		canvas.drawOval(oval, paint);
			canvas.drawRoundRect(backRect, 5, 15, backPaint);
			canvas.drawText(this.corredor, scrnPoint.x +2, scrnPoint.y+15, textStyle);
			canvas.drawText(this.ramal, scrnPoint.x + 2, scrnPoint.y+30, textStyle);	        
	    }
		return true;
    }
	
}
